/*
 * @lc app=leetcode.cn id=1047 lang=javascript
 *
 * [1047] 删除字符串中的所有相邻重复项
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var removeDuplicates = function (s) {
  const stack = [];
  for (const item of s) {
    stack.length === 0 || item !==stack[stack.length - 1] ? stack.push(item) : stack.pop();
  }

  return stack.join('');
};
// @lc code=end
